// 引入axios 
import request from "@/utils/request";
//枚举地址
enum API{
    ALLUSER_URL = "/admin/acl/user/",

  //添加一个新的用户账号
  ADDUSER_URL = '/admin/acl/user/save',
  //更新已有的用户账号
  UPDATEUSER_URL = '/admin/acl/user/update',
  //获取全部角色职位
  ALLROLE_URL = '/admin/acl/user/toAssign/',
  //给已有的用户分配角色
  SETROLE_URL= '/admin/acl/user/doAssignRole',
    // 删除用户
    DELETEUSER_URL = "/admin/acl/user/remove/",
    //批量删除用户
    DELETEALLUSER_URL = "/admin/acl/user/batchRemove"

}
//获取全部用户的数据
export const reqUserInfo = (page: number,limit: number,username:string)=>request.get<any,any>(API.ALLUSER_URL+`${page}/${limit}/?username=${username}`)

//新增或者更新管理用户
export const reqAddOrUpdateUser = (data: any) => {
    //携带参数有ID更新
    if (data.id) {
      return request.put<any, any>(API.UPDATEUSER_URL, data)
    } else {
      return request.post<any, any>(API.ADDUSER_URL, data)
    }
  }
  //获取全部角色职位的数据
export const reqAllRole = (id: number)=>request.get<any,any>(API.ALLROLE_URL+`${id}`)

//分配职位
export const reqSetUserRole = (data: number)=>request.post<any,any>(API.SETROLE_URL,data)

//删除用户的数据
export const reqUserDelete = (id: number)=>request.delete<any,any>(API.DELETEUSER_URL+`${id}`)
//删除用户的数据
export const reqSelectUser = (idList:any)=>request.delete<any,any>(API.DELETEALLUSER_URL,{data:idList})
